/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.main;

import data.ACStorage;
import view.alternative.FrmAddAlternative;
import view.criteria.FrmAddCriteria;
import view.goal.FrmAddGoal;
import view.alternativesrating.FrmRankAlternativesByCriteria;
import view.criteriarating.FrmRankCriterias;
import view.alternativesrating.PnlAlternativeMarks;
import view.alternativesrating.TblModelAlternatives;
import view.criteriarating.PnlCriteriasMarks;
import view.criteriarating.TblModelCriterias;

/**
 *
 * @author Vlada
 */
public class FrmMain extends javax.swing.JFrame {

    /**
     * Creates new form FrmMain
     */
    public FrmMain() {
        initComponents();
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuAdd = new javax.swing.JMenu();
        miAddGoal = new javax.swing.JMenuItem();
        miAddCriteria = new javax.swing.JMenuItem();
        miAddAlternative = new javax.swing.JMenuItem();
        jMenuMarks = new javax.swing.JMenu();
        AlternativeByCriteria = new javax.swing.JMenuItem();
        CriteriaWeights = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenuAdd.setText(" Add");

        miAddGoal.setText("Add goal");
        miAddGoal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miAddGoalActionPerformed(evt);
            }
        });
        jMenuAdd.add(miAddGoal);

        miAddCriteria.setText("Add criteria");
        miAddCriteria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miAddCriteriaActionPerformed(evt);
            }
        });
        jMenuAdd.add(miAddCriteria);

        miAddAlternative.setText("Add alternative");
        miAddAlternative.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miAddAlternativeActionPerformed(evt);
            }
        });
        jMenuAdd.add(miAddAlternative);

        jMenuBar1.add(jMenuAdd);

        jMenuMarks.setText("Marks");

        AlternativeByCriteria.setText("Alternative by criteria");
        AlternativeByCriteria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AlternativeByCriteriaActionPerformed(evt);
            }
        });
        jMenuMarks.add(AlternativeByCriteria);

        CriteriaWeights.setText("Criteria weights");
        CriteriaWeights.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CriteriaWeightsActionPerformed(evt);
            }
        });
        jMenuMarks.add(CriteriaWeights);

        jMenuBar1.add(jMenuMarks);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 281, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void miAddGoalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddGoalActionPerformed
        FrmAddGoal dialogAddGoal = new FrmAddGoal(this, rootPaneCheckingEnabled);
        //  dialogAddGoal.setSize(336,178);
        dialogAddGoal.setLocationRelativeTo(null);
        dialogAddGoal.setVisible(true);
    }//GEN-LAST:event_miAddGoalActionPerformed

    private void miAddAlternativeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddAlternativeActionPerformed
        FrmAddAlternative dialogAddAlternative = new FrmAddAlternative(this, rootPaneCheckingEnabled);

        dialogAddAlternative.setLocationRelativeTo(null);
        dialogAddAlternative.setVisible(true);
    }//GEN-LAST:event_miAddAlternativeActionPerformed

    private void AlternativeByCriteriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AlternativeByCriteriaActionPerformed
        FrmRankAlternativesByCriteria dialog = new FrmRankAlternativesByCriteria(this, rootPaneCheckingEnabled);
        PnlAlternativeMarks pnlAlternativeMarks = new PnlAlternativeMarks();
        TblModelAlternatives tblModel = new TblModelAlternatives(ACStorage.getInstance().getGoal().getListCriteria().get(0));
        pnlAlternativeMarks.getTblAlternativeMarks().setModel(tblModel);
        dialog.setActivePanel(pnlAlternativeMarks);
        dialog.setVisible(true);
    }//GEN-LAST:event_AlternativeByCriteriaActionPerformed

    private void miAddCriteriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddCriteriaActionPerformed
        FrmAddCriteria dialogAddCriteria = new FrmAddCriteria(this, rootPaneCheckingEnabled);
        dialogAddCriteria.setVisible(true);
    }//GEN-LAST:event_miAddCriteriaActionPerformed

    private void CriteriaWeightsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CriteriaWeightsActionPerformed
        FrmRankCriterias dialog = new FrmRankCriterias(this, rootPaneCheckingEnabled);
        PnlCriteriasMarks pnlCriteriaMarks = new PnlCriteriasMarks();
        TblModelCriterias tblModel = new TblModelCriterias(ACStorage.getInstance().getGoal());
        pnlCriteriaMarks.getTblCriteriasMarks().setModel(tblModel);
        dialog.setActivePanel(pnlCriteriaMarks);
        dialog.setVisible(true);


    }//GEN-LAST:event_CriteriaWeightsActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmMain().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem AlternativeByCriteria;
    private javax.swing.JMenuItem CriteriaWeights;
    private javax.swing.JMenu jMenuAdd;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMenuMarks;
    private javax.swing.JMenuItem miAddAlternative;
    private javax.swing.JMenuItem miAddCriteria;
    private javax.swing.JMenuItem miAddGoal;
    // End of variables declaration//GEN-END:variables
}
